package com.lyn.module_custom_network;

import java.util.Map;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;

/**
 * created by lyn at 2021/10/14
 */
public class LynOkHttp {

    private final static class LynOkHttpTypeClass {
        private final static LynOkHttp instance = new LynOkHttp();
    }

    public static LynOkHttp getInstance() {
        return LynOkHttpTypeClass.instance;
    }

    private OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .build();

    private MediaType mediaType = MediaType.parse("application/json; charset=utf-8");


    public String post(Request request) throws Exception{
        Response response = okHttpClient.newCall(request).execute();
        return response.body().string();
    }


    public String get(Request request) throws Exception{
        Response response = okHttpClient.newCall(request).execute();
        return response.body().string();
    }

}
